import { createStore, applyMiddleware } from 'redux';
import { createLogger } from 'redux-logger';
import promiseMiddleware from 'redux-promise-middleware';
import reducers from './reducers';

let middlewares;

if (process.env.NODE_ENV === 'development') {
  middlewares = applyMiddleware(
    createLogger(), /* 状态日志 */
    promiseMiddleware // 异步action管理
  )
} else {
  // 生产环境不要 logger
  middlewares = applyMiddleware(
    promiseMiddleware // 异步action管理
  )
}

console.log();

const store = createStore(
  reducers,
  middlewares
)

export default store;